From f9504d1ff73afc0408bb147526628daff6abbfd4 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 30 Jan 2006 04:15:10 +0000 Subject: [PATCH] More of the less disruptive Garmin changes... Fix polarity of test to allow lowercase letters to X series. If waypoint is unknown on write for D109 or D110, tell the GPS that. Improve readability of debugging code when generating unit ID headers. Rework the product inquiry at startup. Instead of fixed count, read until error. Display session req and request bulk packets when debugging protocol. --- gpsbabel/garmin.c | 3 ++- gpsbabel/jeeps/gps.h | 1 + gpsbabel/jeeps/gpsapp.c | 50 +++++++++++++++++++++++++++-------------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 1e269960a..a0c4be9d9 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -163,7 +163,7 @@ rw_init(const char *fname) * Until Garmins documents how to determine valid character space * for the new models, we just release this safety check manually. */ - if (!receiver_must_upper) + if (receiver_must_upper) setshort_goodchars(mkshort_handle, valid_waypt_chars); setshort_mustupper(mkshort_handle, receiver_must_upper); @@ -523,6 +523,7 @@ waypoint_write(void) } way[i]->smbl = icon; if (wpt->altitude == unknown_alt) { + way[i]->alt_is_unknown = 1; way[i]->alt = 0; } else { way[i]->alt = wpt->altitude; diff --git a/gpsbabel/jeeps/gps.h b/gpsbabel/jeeps/gps.h index 327b4e565..7fd2ad701 100644 --- a/gpsbabel/jeeps/gps.h +++ b/gpsbabel/jeeps/gps.h @@ -130,6 +130,7 @@ typedef struct GPS_SWay int32 colour; char cc[2]; UC wpt_class; + UC alt_is_unknown; float alt; char city[24]; char state[2]; diff --git a/gpsbabel/jeeps/gpsapp.c b/gpsbabel/jeeps/gpsapp.c index 488ad0f28..a2f0d3bca 100644 --- a/gpsbabel/jeeps/gpsapp.c +++ b/gpsbabel/jeeps/gpsapp.c @@ -23,6 +23,7 @@ ** Boston, MA 02111-1307, USA. ********************************************************************/ #include "gps.h" +#include "garminusb.h" #include #include #include @@ -209,14 +210,11 @@ static int32 GPS_A000(const char *port) version = GPS_Util_Get_Short((rec->data)+2); (void) strcpy(gps_save_string,(char *)rec->data+4); - GPS_User((char *)rec->data+4); - (void) sprintf(tstr,"ID:\t\t%d\n",id); gps_save_id = id; - GPS_User(tstr); gps_save_version = (double)((double)version/(double)100.); - (void) sprintf(tstr, - "Version:\t%.2f\n",gps_save_version); - GPS_User(tstr); + + GPS_User("Unit:\t%s\nID:\t%d\nVersion:\t%.2f", + gps_save_string, gps_save_id, gps_save_version); gps_date_time_transfer = pA600; @@ -241,21 +239,30 @@ static int32 GPS_A000(const char *port) } else { - int maxct = 3; + int i; /* * The unit may return more than one packet, so read and - * discard all but the product inquiry response. + * discard all but the product inquiry response. We have + * no way of knowing how many we'll get, so we have to keep + * reading until we incur a timeout. */ - while (maxct--) { - (void) GPS_Packet_Read(fd, &rec); - GPS_Send_Ack(fd, &tra, &rec); - if (rec->type == 0xfd) { - GPS_A001(rec); - break; - } + for (i = 0; i < 25; i++) { + rec->type = 0; + + if (GPS_Packet_Read(fd, &rec) < 0) { + goto carry_on; + } + + GPS_Send_Ack(fd, &tra, &rec); + + if (rec->type == 0xfd) { + GPS_A001(rec); + } } + fatal("Failed to find a product inquiry response.\n"); } +carry_on: /* Make sure PVT is off as some GPS' have it on by default */ if(gps_pvt_transfer != -1) GPS_A800_Off(port,&fd); @@ -1998,7 +2005,11 @@ static void GPS_D109_Send(UC *data, GPS_PWay way, int32 *len, int protoid) p+=sizeof(int32); GPS_Util_Put_Int(p,(int32)GPS_Math_Deg_To_Semi(way->lon)); p+=sizeof(int32); - GPS_Util_Put_Float(p,way->alt); + if (way->alt_is_unknown) { + GPS_Util_Put_Float(p,1.0e25); + } else { + GPS_Util_Put_Float(p,way->alt); + } p+=sizeof(float); GPS_Util_Put_Float(p,way->dpth); p+=sizeof(float); @@ -5290,7 +5301,6 @@ time_t GPS_A600_Get(const char *port) if(!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New())) return MEMORY_ERROR; - GPS_Util_Put_Short(data, COMMAND_ID[gps_device_command].Cmnd_Transfer_Time); GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data, @@ -6021,5 +6031,11 @@ Get_Pkt_Type(unsigned char p, unsigned char d0, const char **xinfo) return "PRDREQ"; if (p == LT.Pid_Product_Data) return "PRDDAT"; + if (p == GUSB_REQUEST_BULK) + return "REQBLK"; + if (p == GUSB_SESSION_START) + return "SESREQ"; + if (p == GUSB_SESSION_ACK) + return "SESACK"; return "UNKNOWN"; } -- 2.30.2